<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    全选 <input type="checkbox" class="checkAll">
    <br>
    <input type="checkbox" class="checkOne">
    <input type="checkbox" class="checkOne">
    <input type="checkbox" class="checkOne">
    <input type="checkbox" class="checkOne">

    <script>

        // 全选
        var oAll = document.querySelector('.checkAll');
        // 所有的单选
        var oOnes = document.querySelectorAll('.checkOne');

        // 循环绑定事件
        for(var i = 0 ; i < oOnes.length ; i++) {
            oOnes[i].onclick = function() {
                // alert(888)
                //    每一次点击的时候，都要看所有的单选的状态
                var count = 0 ;
                // 循环判断
                for(var j = 0 ; j < oOnes.length ; j++) {
                    if(oOnes[j].checked) {
                        count++ ;
                    }
                }
                console.log(count);
                if(count === oOnes.length) {
                    oAll.checked = true ;
                } else {
                    oAll.checked = false ;
                }
               
            }
        }

    </script>

</body>

</html>